/*     */ package nc.bs.pu.m20.maintain;
/*     */ 
/*     */ import java.io.Serializable;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import nc.bs.pu.m20.maintain.rule.ATPAfterUpdateRule;
/*     */ import nc.bs.pu.m20.maintain.rule.ATPBeforeUpdateRule;
/*     */ import nc.bs.pu.m20.maintain.rule.insert.BillCodeRule;
/*     */ import nc.bs.pu.m20.maintain.rule.insert.FillInsertPraybillVos;
/*     */ import nc.bs.pu.m20.maintain.rule.insert.InsertAfterEventRule;
/*     */ import nc.bs.pu.m20.maintain.rule.insert.InsertBeforeEventRule;
import nc.bs.pu.m20.maintain.rule.insert.WriteDMOWhenInsertRule;
import nc.bs.pu.m20.maintain.rule.insert.WriteE7WhenInsertRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.BillCodeCheckUniqueRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.BodyEmptyRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.ChkLenRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.DirecttransitAndSctype;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.FillDownNumRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.NotNullRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.NumAndOrigmnySumRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.NumCheckRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.RownoCheckRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.TranstypeCheck;
/*     */ import nc.bs.pu.m20.plugin.PraybillPluginPoint;
/*     */ import nc.impl.pubapp.bd.userdef.UserDefSaveRule;
/*     */ import nc.impl.pubapp.pattern.data.bill.BillInsert;
/*     */ import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
/*     */ import nc.vo.pu.m20.entity.PraybillItemVO;
/*     */ import nc.vo.pu.m20.entity.PraybillVO;
/*     */ import nc.vo.pu.m20.enumeration.EnumOperate;
/*     */ import nc.vo.pu.pub.rule.NewestOrgVersionFillRule;
/*     */ import nc.vo.pu.pub.rule.TrantypeNotNullCheckRule;
/*     */ import nc.vo.pu.pub.rule.WriteBackPIMRule;
/*     */ import nc.vo.pub.BusinessException;
/*     */ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
/*     */ import nc.vo.scmpub.res.billtype.POBillType;
/*     */ import nc.vo.scmpub.rule.AutoMaterialAssignRule;
/*     */ import nc.vo.scmpub.rule.StockOrgEnableCheckRule;
/*     */ import nccloud.commons.lang.ArrayUtils;
/*     */ import nccloud.pubitf.pu.pub.util.PuSagasUtil;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class PraybillInsertBP
/*     */ {
/*     */   public PraybillVO[] insert(PraybillVO[] aggVO) {
/*  72 */     AroundProcesser<PraybillVO> processer = new AroundProcesser<PraybillVO>(PraybillPluginPoint.INSERT);
/*     */ 
/*     */ 
/*     */     
/*  76 */     addBeforeRule(processer);
/*  77 */     addAfterRule(processer);
/*     */     
/*  79 */     processer.before(aggVO);
/*     */     
/*  81 */     BillInsert<PraybillVO> bo = new BillInsert<PraybillVO>();
/*     */     
/*  83 */     PraybillVO[] vos = (PraybillVO[])bo.insert(aggVO);
/*     */     
/*  85 */     addSagaAndCompensate(aggVO);
/*  86 */     processer.after(aggVO);
/*     */     
/*  88 */     (new PraybillWriteBackSourceRule(EnumOperate.ADD)).process(vos, null);
/*     */     
/*  90 */     (new ATPAfterUpdateRule()).process(vos);
/*     */ 
/*     */     
/*  93 */     (new WriteBackPIMRule(POBillType.PrayBill.getCode())).process(vos, null);
/*     */ 
/*     */ 
/*     */     
/*  97 */     return vos;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void addAfterRule(AroundProcesser<PraybillVO> processer) {
/* 116 */     processer.addAfterRule(new BillCodeCheckUniqueRule());
/*     */     
/* 118 */     processer.addAfterRule(new InsertAfterEventRule());

processer.addAfterRule(new WriteDMOWhenInsertRule());
processer.addAfterRule(new WriteE7WhenInsertRule());
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void addBeforeRule(AroundProcesser<PraybillVO> processer) {
/* 127 */     processer.addBeforeRule(new BodyEmptyRule());
/*     */     
/* 129 */     processer.addBeforeFinalRule(new NotNullRule());
/*     */     
/* 131 */     processer.addBeforeFinalRule(new TrantypeNotNullCheckRule());
/*     */     
/* 133 */     processer.addBeforeFinalRule(new NewestOrgVersionFillRule("pk_praybill"));
/*     */ 
/*     */     
/* 136 */     processer.addBeforeRule(new FillInsertPraybillVos());
/*     */     
/* 138 */     processer.addBeforeRule(new FillDownNumRule());
/*     */     
/* 140 */     processer.addBeforeFinalRule(new ChkLenRule());
/*     */     
/* 142 */     processer.addBeforeRule(new NumCheckRule());
/*     */ 
/*     */     
/* 145 */     processer.addBeforeRule(new BillCodeRule());
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 153 */     processer.addBeforeRule(new RownoCheckRule());
/*     */     
/* 155 */     processer.addBeforeRule(new StockOrgEnableCheckRule());
/*     */     
/* 157 */     processer.addBeforeFinalRule(new DirecttransitAndSctype());
/*     */     
/* 159 */     processer.addBeforeFinalRule(new TranstypeCheck());
/*     */     
/* 161 */     processer.addBeforeRule(new AutoMaterialAssignRule("pk_material", null, new String[] { "pk_org", "pk_purchaseorg" }));
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 171 */     processer.addBeforeFinalRule(new NumAndOrigmnySumRule());
/*     */     
/* 173 */     processer.addBeforeRule(new UserDefSaveRule(new Class[] { nc.vo.pu.m20.entity.PraybillHeaderVO.class, PraybillItemVO.class }));
/*     */ 
/*     */ 
/*     */     
/* 177 */     processer.addBeforeFinalRule(new ATPBeforeUpdateRule());
/*     */     
/* 179 */     processer.addBeforeRule(new InsertBeforeEventRule());
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void addSagaAndCompensate(PraybillVO[] vos) {
/*     */     try {
/* 195 */       PuSagasUtil.frozenAndAddSaga(vos, POBillType.PrayBill.getCode());
/* 196 */       List<String> hList = new ArrayList<String>();
/* 197 */       List<String> bList = new ArrayList<String>();
/* 198 */       for (PraybillVO praybillVO : vos) {
/* 199 */         PraybillItemVO[] praybillItemVOs = praybillVO.getBVO();
/* 200 */         if (!ArrayUtils.isEmpty(praybillItemVOs)) {
/*     */ 
/*     */           
/* 203 */           hList.add(praybillVO.getHVO().getPk_praybill());
/* 204 */           for (PraybillItemVO praybillItemVO : praybillItemVOs)
/* 205 */             bList.add(praybillItemVO.getPk_praybill_b()); 
/*     */         } 
/*     */       } 
/* 208 */       Map<String, Serializable> map = new HashMap<String, Serializable>();
/* 209 */       map.put("opertaion", "praybillInsert");
/* 210 */       map.put("pk_praybill_b", bList
/* 211 */           .toArray(new String[bList.size()]));
/* 212 */       map.put("pk_praybill", hList
/* 213 */           .toArray(new String[hList.size()]));
/*     */       
/* 215 */       PuSagasUtil.compensate(nc.itf.pu.m20.compenstate.IBuyingreqM4A08SagasCompensate.class, map);
/* 216 */     } catch (BusinessException e) {
/* 217 */       ExceptionUtils.wrappException(e);
/*     */     } 
/*     */   }
/*     */ }


/* Location:              E:\zhuhai_ncc\NCC2111\modules\pu\META-INF\lib\pu_buyingreq.jar!/nc/bs/pu/m20/maintain/PraybillInsertBP.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */